package com.hshoesmall.demo.controller;

import com.hshoesmall.demo.common.api.ApiResult;
import com.hshoesmall.demo.model.entity.Size;
import com.hshoesmall.demo.service.SizeService;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sizes")
public class SizeController {

    @Resource
    private SizeService sizeService;

    @RequestMapping(value="/getAllSizes", method = RequestMethod.POST)
    public ApiResult<Map<String, Object>> getSizeList() {

        List<Size> size = sizeService.findSizeList();
        if (ObjectUtils.isEmpty(size)) {
            return ApiResult.failed("操作失败");
        }
        Map<String, Object> map = new HashMap<>(16);
        map.put("size", size);
        return ApiResult.success(map);
    }


}
